package dataModel;

import java.util.List;
import java.util.Map;

public class Product {
	private int id;

	// composed product with params and reviews
	Map<String, String> params = null;
	List<Review> reviews = null;

	public String getParamString() {
		String result = "";

		if(params == null)
			return result;
		
		for (String key : params.keySet())
			result = result.concat(key + " : " + params.get(key) + "; ");
		return result;
	}

	public String getReviewString() {
		String result = "";
		if(reviews == null)
			return result;
		
		for (Review review : reviews)
			result = result.concat(review.getGoodQuality() + "; "
					+ review.getBadQuality() + "; " + review.getSummary()
					+ "\n\r");
		return result;
	}

	public Map<String, String> getParams() {
		return params;
	}

	public void setParams(Map<String, String> params) {
		this.params = params;
	}

	public List<Review> getReviews() {
		return reviews;
	}

	public void setReviews(List<Review> reviews) {
		this.reviews = reviews;
	}

	// simple product elems
	private String hashId = "";

	private String title;
	private String href;

	private float highPrice;
	private float lowPrice;

	private float rating;

	private int commentNum;
	private String commentUrl;

	public int getId() {
		return id;
	}

	public void setId(int id) {
		this.id = id;
	}

	public String getHashId() {
		return hashId;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public String getHref() {
		return href;
	}

	public void setHref(String href) {
		this.href = href;

		if (href.indexOf("&id=") != -1)
			this.hashId = href.substring(href.indexOf("&id=") + 4);
		else
			this.hashId = "";
	}

	public float getHighPrice() {
		return highPrice;
	}

	public void setHighPrice(float highPrice) {
		this.highPrice = highPrice;
	}

	public float getLowPrice() {
		return lowPrice;
	}

	public void setLowPrice(float lowPrice) {
		this.lowPrice = lowPrice;
	}

	public float getRating() {
		return rating;
	}

	public void setRating(float rating) {
		this.rating = rating;
	}

	public int getCommentNum() {
		return commentNum;
	}

	public void setCommentNum(int commentNum) {
		this.commentNum = commentNum;
	}

	public String getCommentUrl() {
		return commentUrl;
	}

	public void setCommentUrl(String commentUrl) {
		this.commentUrl = commentUrl;
	}

	@Override
	public String toString() {
		return id + " [commentNum=" + commentNum + ", commentUrl=" + commentUrl
				+ ", href=" + href + ", highPrice=" + highPrice + ", lowPrice="
				+ lowPrice + ", rating=" + rating + ", title=" + title + "]";
	}
}
